﻿using LiteBlog.Common.Entities;
using LiteBlog.Repositories.Common;
using LiteBlog.XmlLayer.Mocks.Constants;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using LiteBlog.Repositories;

namespace LiteBlog.Repositories.Tests
{
    [TestClass]
    public class SettingsDataLoadCompTests : LoadCompTests<Settings, SettingsRepository>
    {


        protected override void SetupLoad()
        {
            
        }

        protected override Settings SetupSave()
        {
            SetupLoad();
            var settings = new Settings();
            settings.Name = SettingsDataTestConstants.NameSetting;
            settings.PostCount = SettingsDataTestConstants.PostCountSetting + 1;
            settings.CommentModeration = !SettingsDataTestConstants.ModerationSetting;
            return settings;
        }

        protected override bool VerifySave(XElement root)
        {
            bool result = root != null;
            result = result && root.Element(Elem.Name).Value.Equals(SettingsDataTestConstants.NameSetting);
            result = result && ((int)root.Element(Elem.PostCount) == (SettingsDataTestConstants.PostCountSetting + 1));
            result = result && ((bool)root.Element(Elem.CommentModeration) == !SettingsDataTestConstants.ModerationSetting);
            return result;
        }
    }
}
